<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>表单模块 - layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">

  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css">

<style>
body{padding: 10px;}
</style>
</head>
<body>
<div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li><a href="{:url('admin/news/index')}" class="a_menu">新闻管理</a></li>
        <li class="layui-this" id="aaa">添加新闻</li>
      </ul>
    </div>
<form class="layui-form" id="form"  enctype='multipart/form-data'>
<input type="hidden" name="id" value="{$news.id??''}">
<div class="layui-form-item">
    <label class="layui-form-label">新闻类型</label>
    <div class="layui-input-block">
      <select name="type" lay-filter="interest">
        <option value="">请选择</option>
        <option value="1" {notempty name="$news.type"}{if $news.type == '1'}selected{/if}{/notempty}>行业大事件</option>
        <option value="2" {notempty name="$news.type"}{if $news.type == '2'}selected{/if}{/notempty}>热点新闻</option>
      </select>
    </div>
  </div>
  <div class="layui-form-item">
   <div class="layui-form-item" id="admin">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" type="text" value="{$news.title??''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">副标题</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="subtitle" lay-verify="subtitle" autocomplete="off" placeholder="请输入副标题" class="layui-input" type="text" value="{$news.subtitle??''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">作者</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="author" lay-verify="author" autocomplete="off" placeholder="请输入作者" class="layui-input" type="text" value="{$news.author??''}">
        </div>
      </div>
	  <div class="layui-form-item">
        <label class="layui-form-label">页面TITLE</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="tit" lay-verify="subtitle" autocomplete="off" placeholder="请输入副标题" class="layui-input" type="text" value="{$news.tit??''}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">关键词</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="key" lay-verify="author" autocomplete="off" placeholder="请输入关键词,请用英文,隔开" class="layui-input" type="text" value="{$news.key??''}">
        </div>
      </div>
	        <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">描述</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入描述" name="dec" class="layui-textarea">{notempty name="$news.dec"}{$news.dec}{/notempty}</textarea>
    </div>
  </div>
      <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-block" style="max-width:600px;">
          <input name="img" type="file" >
        </div>
      </div>
       {notempty name="$news.img"}
        <div class="layui-form-item">
        <div class="layui-input-block" style="max-width:600px;">
          <img width="150" height="150" src="__UPLOAD__/news/{$news.img}">
        </div>
      </div>
      {/notempty}
  
  <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block" style="max-width:1000px;">
          <textarea placeholder="请输入内容" class="layui-textarea" name="content" id="container" style="border:0;padding:0">{notempty name="$news.content"}{$news.content}{/notempty}</textarea>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline" style="max-width:600px;">
          <input name="type_sort" lay-verify="type_sort" autocomplete="off" placeholder="请输入排序" class="layui-input" type="text" value="{$news.type_sort??''}">
        </div>
        <div class="layui-form-mid layui-word-aux">默认是 999</div>
      </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<br><br><br>


<script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script src="__JS__/form.js"></script>
    <script src="__JS__/layer.js"></script>
<script>
      
      layui.use(['layer', 'form'], function() {
          var layer = layui.layer,
              $ = layui.jquery,
              form = layui.form;
          $(window).on('load', function() {
              form.on('submit(admin)', function(data) {
                  
          $("#form").ajaxSubmit({
          type: 'post',  
          dataType:"json",
          url:"{:url('admin/news/add')}",
          success: function(res){
            <!-- console.log(res);return false; -->
            if(res.code == 1) {
              layer.alert(res.msg, function(index){
                location.href = res.url;
              })
            } else {
              layer.msg(res.msg);
              }
          },  
          error: function(XmlHttpRequest, textStatus, errorThrown){  
            alert( "error");  
          }  
        });
                  return false;
              });
          });
      });
    </script>
<!-- <script src="__CSS__/../layui.all.js"></script> -->
<!-- 加载编辑器的容器 -->
    <script id="container" name="content" type="text/plain">
        这里写你的初始化内容
    </script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
    </script>
<script>
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
 laydate.render({
    elem: '#test'
    ,type: 'datetime'
  });
 laydate.render({
    elem: '#test1'
    ,type: 'datetime'
  });
  
  
});
</script>
</body>
</html>
